/**
 * Created by lixiaodi on 2018/11/8.
 */
//模拟数据
var moniData = [
	{
		taskId : 1,
		taskName : '测试任务名称1',
		createDate : '2019-03-01'
	},
	{
		taskId : 2,
		taskName : '测试任务名称2',
		createDate : '2019-03-01'
	}
]




mini.parse();
//得到数据表
var grid = mini.get("waitDatagrid");
var menu = new ColumnsMenu(grid);       //表头添加菜单按钮
//加载数据表数据(初始化)
$(function(){
    httpList();
})
//弹出窗口路径前缀
var url = bootPATH + "../frame/frame1/pages/";
//办理任务
function flowProcess(){
    var jumpUrls = url +"activiti/datagridDetail/approvalDetail.html";
    var titles = "经理审批";
    //跳转页面
    jumpPage(jumpUrls,titles);
}
//查看流程图
function seeImg(){
    //得到选中行
    var row = grid.getSelected();
    var taskId = row.taskId;
    $.ajax({
        url: ajaxUrl + "/activitiTaskController/showCurrentView.do?taskId=" + taskId ,
        type:"post",
        success: function (data) {
        	console.log(data);
            //grid.setData(data.data)
            //grid.reload();
        },
        error: function () {
            mini.alert("失败");
        }
    });
}


//得到选中行以后跳转页面
function jumpPage(jumpUrl,title){
    //得到选中行
    var row = grid.getSelected();
    if (row) {
    	//打开审批页面
        mini.open({
            url: jumpUrl,
            title: title,
            width: 600,
            height: 500,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = {
                    action: "see",
                    nowTask : row,
                    taskId : row.taskId
                };
                iframe.contentWindow.SetData(data);
            },
            ondestroy: function (action) {
            	grid.setData(moniData);
            }
        });
    }else {
        mini.alert("请选中一条记录");
    }
}
//刷新
function refresh(){
	httpList();
}
//list请求
function httpList(){
	$.ajax({
        url: ajaxUrl + "/activitiTaskController/taskPage.do",
        type:"post",
        datatype:"json",
        success: function (data) {
        	console.log(data);
            grid.setData(data.data)
            //grid.reload();
        },
        error: function () {
            mini.alert("失败");
        }
    });
}